package com.xuecheng.content.api;

import com.xuecheng.base.exception.ValidationGroups;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 师资信息编辑接口
 * Package: com.xuecheng.content.api
 * Description:
 *
 * @Author Endeavor-ZQB
 * @Create 2023/1/31 16:28
 * @Version 1.0
 */
@Api(value = "师资信息编辑接口",tags = "师资信息编辑接口")
@RestController
@Slf4j
public class CourseTeacherController {

    @Autowired
    CourseTeacherService courseTeacherService;

    @ApiOperation("根据课程id查询师资信息")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> getCourseTeacher(@PathVariable Long courseId){
        List<CourseTeacher> courseTeacher = courseTeacherService.getCourseTeacher(courseId);
        return courseTeacher;
    }

    @ApiOperation("添加课程的师资信息")
    @PostMapping("/courseTeacher")
    public CourseTeacher addCourseTeacher(@RequestBody @Validated({ValidationGroups.Insert.class}) CourseTeacher courseTeacher){
       return courseTeacherService.addCourseTeacher(courseTeacher);

    }

    @ApiOperation("删除课程的师资信息")
    @DeleteMapping("/courseTeacher/course/{courseId}/{courseTeacherId}")
    public void deleteCourseTeacheById(@PathVariable Long courseId, @PathVariable Long courseTeacherId){
        courseTeacherService.deleteCourseTeacheById(courseId,courseTeacherId);

    }
}
